using System;
using System.Collections.Generic;
using System.Diagnostics;

public static class OverlayQue
{
	public static void ResetOverlays()
	{
		OverlayQue.overlayInfos = new List<OverlayQue.OverlayIInfo>();
	}

	//[DebuggerBrowsable(DebuggerBrowsableState.Never)]
	public static event Action<bool, string> onOverlayAction;

	public static void Add(string overlayName, object param = null)
	{
		OverlayQue.overlayInfos.Add(new OverlayQue.OverlayIInfo(overlayName, param));
	}

	public static void CloseOverlay(string overlayName)
	{
		OverlayQue.overlayInfos.RemoveAt(0);
		OverlayQue.isOpenedOverlay = false;
		Scene.CloseOverlay(overlayName);
	}

	public static void Process()
	{
		if (!OverlayQue.available)
		{
			return;
		}
		if (OverlayQue.isOpenedOverlay)
		{
			return;
		}
		if (OverlayQue.overlayInfos.Count <= 0)
		{
			return;
		}
		if (OverlayQue.onOverlayAction != null)
		{
			OverlayQue.onOverlayAction(true, OverlayQue.overlayInfos[0].name);
		}
		Scene.ShowOverlay(OverlayQue.overlayInfos[0].name, OverlayQue.overlayInfos[0].param);
		OverlayQue.isOpenedOverlay = true;
	}

	public static bool isOpenedOverlay = false;

	private static List<OverlayQue.OverlayIInfo> overlayInfos = new List<OverlayQue.OverlayIInfo>();

	public static bool available = true;

	private class OverlayIInfo
	{
		public OverlayIInfo(string _name, object _param)
		{
			this.name = _name;
			this.param = _param;
		}

		public string name;

		public object param;
	}
}
